var obj = new MyObj();

function MyObj() {
    this.cabinetMouth = null;  	// 更到的空闲格口
    this.malfunction = 1;			// 故障状态码
    this.type = null;				// 处理方式
}

$("#replace").click(function () {
    $("#cabinetTwo").show();
});
$(".wk").click(function (e) {
    var eleId = e.target.className;
    if (eleId == "wk") {
        $(".cabinetOne").hide();
    }
});

$("#malfunctionOne div").click(function () {
    obj.malfunction = parseInt($(this).attr("data-malfunction"));
    $(this).addClass("active").siblings().removeClass("active");
});


$("#malfunctionAreaTwo div").click(function () {
    obj.type = parseInt($(this).attr("data-type"));
    if (obj.type == 2) {
        $(".sunyan").show();
    } else {
        $(".sunyan").hide();
    }
    $(this).addClass("active").siblings().removeClass("active");
});

$("#cabinetTwo .itemNum div").click(function () {
    var num = $(this).attr("num");
    var clsName = $(this).prop("className");
    if (clsName == "man") {
        mui.alert("此格口已有人使用。", "格口选择", "确定");
    } else {
        mui.confirm("确认选择此格口?", "格口选择", ["取消", "确定"], function (res) {
            console.log(res);
            if (res.index == 1) {
                obj.cabinetMouth = parseInt(num);
                console.log(obj);
                $("#replace").text("更换至空闲格口 -" + num);
                $("#cabinetTwo").hide();
            }
        })
    }
});

$("#tijiao").click(function () {
    if (obj.type == null || obj.type == undefined) {
        mui.alert("请选择故障的处理方式", "提示", "确认");
    } else if (obj.type == 1 && obj.type) {
        if (obj.cabinetMouth == null || obj.cabinetMouth == undefined) {
            mui.alert("请选择要更换至的格口", "提示", "确认");
            return false;
        }
    }
    if (obj.malfunction == null || obj.malfunction == undefined) {
        mui.alert("请选择故障类型", "提示", "确认");
        return false;
    }
    console.log(obj);
    mui.alert("感谢您的反馈, 我们会尽快维修。", "提交完成", "确认");
    return false;
    var detail = $("#malfunctionDetail").val();
    var data = obj;
    data.detail = detail;
    $.ajax({
        url: "",
        type: "POST",
        data: data,
        success: function (res) {
            mui.alert("感谢您的反馈, 我们会尽快维修。", "提交完成", "确认");
        }
    });
});
